<template>
    <div>
        <Modal
            v-model="isVisible"
            width="1150"
            title="授权管理"
            class-name="licenseBox">

            <roomLicens :lockDetail="lockInfo" :roomName="roomName"></roomLicens>

            <div slot="footer">
                <Button type="ghost" size="large" @click="hideModal">关闭</Button>
            </div>

        </Modal>
    </div>
</template>

<script>
import roomLicens from './roomLicens.vue'

export default {
  name: 'licenseRecord',
  components: {
    roomLicens
  },
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    room: {
      // 单个门锁设备详情
      required: true
    },
    home: {
      required: true
    },
    roomName: {
      // 房间名称
      type: String
    }
  },
  data () {
    return {
      lockInfo: {}
    }
  },
  created () {
    this.lockInfo.roomInfo = this.room
    this.lockInfo.roomName = this.room.room_name
    this.lockInfo.homeInfo = this.home
    if (!this.lockInfo.flag) {
      this.lockInfo.roomId = this.room.id
      this.room.devices.forEach(item => {
        if (item.device_type === 2) {
          this.lockInfo.parent = item.parent
          this.lockInfo.id = item.id
          this.lockInfo.sn = item.sn
        }
      })
      this.lockInfo.flag = true
    }
  },
  computed: {
    isVisible: {
      get: function () {
        return this.visible
      },

      set: function () {
        this.$emit('on-close')
      }
    }
  },
  methods: {
    hideModal () {
      this.isVisible = false
    }
  }
}
</script>

<style lang="less">
// .licenseBox {
//     z-index: 1002 !important;
// }
</style>